<template>
    <div>
        <NavBar :title="title"></NavBar>
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in categoriesApiData" :title="item.cat_name" />
                </van-sidebar>
            </van-col>
            <van-col span="18">

                <Swipe :images="images" :imgwidth="imgwidth" :imgheight="imgheight"></Swipe>
                <div v-for="item in categoriesApiData[active]?.children">
                    <h3>{{ item.cat_name }}</h3>

                    <router-link :to="{ name: 'goods', params: { query: item.cat_name } }">
                        <van-grid :column-num="4">
                            <van-grid-item v-for="items in item.children" :icon="items.cat_icon"
                                :text="items.cat_name" />
                        </van-grid>
                    </router-link>

                </div>


            </van-col>

        </van-row>
    </div>
</template>

<script setup>
import Swipe from '@/components/Swipe.vue';
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-8.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-7.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-6.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-5.jpeg',
];
const imgwidth = '100%'
const imgheight = '100px'
import NavBar from '@/components/NavBar.vue';
const title = '分类'
import { ref } from 'vue';
const categoriesApiData = ref([])
import { categoriesApi } from '@/api/api';
categoriesApi().then(res => {
    console.log(res);
    categoriesApiData.value = res.data.message
})
const active = ref(0)
</script>

<style lang="scss" scoped></style>